home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / ab20_archive / text / cmanual.lzh / ACM3.lzh / AmigaDOS / Example6.c < prev    next >
C/C++ Source or Header  |  1991-01-12  |  1KB  |  58 lines

  1. /* Example6                                                      */
  2. /* This example demonstrates how to protect and unprotect files. */
  3. /* The file Example 5 created ("Letter.doc") will be protected,  */
  4. /* and we will then try to delete it (unsuccessfully). We will   */
  5. /* then unprotect the file and then try to delete it             */
  6. /* (successfully).                                               */  
  7.  
  8.  
  9. /* Declares BOOL: */
  10. #include <exec/types.h>
  11. /* Declares the FileHandle structure: */
  12. #include <libraries/dos.h>
  13.  
  14.  
  15. void main();
  16.  
  17. void main()
  18. {
  19.   BOOL ok;
  20.  
  21.  
  22.   /* Protect the file: */
  23.   ok = SetProtection( "RAM:Letter.doc", FIBF_DELETE );
  24.  
  25.   /* Check if the file was successfully protected: */
  26.   if( !ok )
  27.     printf( "Could not protect the file!\n" );
  28.  
  29.  
  30.   /* Try to delete the file: */
  31.   ok = DeleteFile( "RAM:Letter.doc" );
  32.  
  33.   /* Check if the file was successfully deleteted: */
  34.   if( !ok )
  35.     printf( "Could not delete the file!\n" );
  36.   else
  37.     printf( "File deleted!\n" );
  38.  
  39.  
  40.  
  41.   /* Unprotect the file: */
  42.   ok = SetProtection( "RAM:Letter.doc", NULL );
  43.  
  44.   /* Check if the file was successfully unprotected: */
  45.   if( !ok )
  46.     printf( "Could not unprotect the file!\n" );
  47.  
  48.  
  49.   /* Try to delete the file: */
  50.   ok = DeleteFile( "RAM:Letter.doc" );
  51.  
  52.   /* Check if the file was successfully deleteted: */
  53.   if( !ok )
  54.     printf( "Could not delete the file!\n" );
  55.   else
  56.     printf( "File deleted!\n" );
  57. }
  58.